home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / pm-utils / module.d / uswsusp < prev   
Encoding:
Text File  |  2009-04-07  |  3.1 KB  |  110 lines

  1. #!/bin/sh
  2.  
  3. # disable processing of 90chvt and 99video.
  4. # s2ram and s2disk handle all this stuff internally.
  5. uswsusp_hooks()
  6. {
  7.     disablehook 90chvt "disabled by uswsusp"
  8.     disablehook 99video "disabled by uswsusp"
  9. }
  10.  
  11. # Since we disabled 99video, we need to take responsibility for proper
  12. # quirk handling.  s2ram handles all common video quirks internally,
  13. # so all we have to do is translate the HAL standard options to s2ram options.
  14. uswsusp_get_quirks()
  15. {
  16.     OPTS=""
  17.     ACPI_SLEEP=0
  18.     for opt in $PM_CMDLINE; do
  19.         case "${opt##--quirk-}" in # just quirks, please
  20.             dpms-on)        ;; # no-op
  21.             dpms-suspend)        ;; # no-op
  22.             radeon-off)        OPTS="$OPTS --radeontool" ;;
  23.             reset-brightness)  ;; # no-op
  24.             s3-bios)        ACPI_SLEEP=$(($ACPI_SLEEP + 1)) ;;
  25.             s3-mode)        ACPI_SLEEP=$(($ACPI_SLEEP + 2)) ;;
  26.             vbe-post)        OPTS="$OPTS --vbe_post" ;;
  27.             vbemode-restore)   OPTS="$OPTS --vbe_mode" ;;
  28.             vbestate-restore)  OPTS="$OPTS --vbe_save" ;;
  29.             vga-mode3)        ;; # no-op
  30.             save-pci)          OPTS="$OPTS --pci_save" ;;
  31.             none)            QUIRK_NONE="true" ;;
  32.             *) continue ;;
  33.         esac
  34.     done
  35.     [ $ACPI_SLEEP -ne 0 ] && OPTS="$OPTS --acpi_sleep $ACPI_SLEEP"
  36.     # if we were told to ignore quirks, do so.
  37.     # This is arguably not the best way to do things, but...
  38.     [ "$QUIRK_NONE" = "true" ] && OPTS=""
  39. }
  40.  
  41. # Since we disabled 99video, we also need to handle displaying
  42. # help info for the quirks we handle.
  43. uswsusp_help()
  44. {
  45.     echo  # first echo makes it look nicer.
  46.     echo "s2ram video quirk handler options:"
  47.     echo
  48.     echo "  --quirk-radeon-off"
  49.     echo "  --quirk-s3-bios"
  50.     echo "  --quirk-s3-mode"
  51.     echo "  --quirk-vbe-post"
  52.     echo "  --quirk-vbemode-restore"
  53.     echo "  --quirk-vbestate-restore"
  54.     echo "  --quirk-save-pci"
  55.     echo "  --quirk-none"
  56. }
  57.  
  58. # This idiom is used for all sleep methods.  Only declare the actual
  59. # do_ method if:
  60. # 1: some other sleep module has not already done so, and
  61. # 2: this sleep method can actually work on this system.
  62. #
  63. # For suspend, if SUSPEND_MODULE is set then something else has already
  64. # implemented do_suspend.  We could just check to see of do_suspend was
  65. # already declared using command_exists, but using a dedicated environment
  66. # variable makes it easier to debug when we have to know what sleep module
  67. # ended up claiming ownership of a given sleep method.
  68. if [ -z "$SUSPEND_MODULE" ] && command_exists s2ram && \
  69.     ( grep -q mem /sys/power/state || \
  70.         ( [ -c /dev/pmu ] && check_suspend_pmu; ); ); then
  71.     SUSPEND_MODULE="uswsusp"
  72.     do_suspend()
  73.     {
  74.         uswsusp_get_quirks
  75.         s2ram --force $OPTS
  76.     }
  77.     if [ "$METHOD" = "suspend" ]; then
  78.         add_before_hooks uswsusp_hooks
  79.         add_module_help uswsusp_help
  80.     fi
  81. fi
  82.  
  83. if [ -z "$HIBERNATE_MODULE" ] && \
  84.     [ -f /sys/power/disk ] && \
  85.     grep -q disk /sys/power/state && \
  86.     [ -c /dev/snapshot ] &&
  87.     command_exists s2disk; then
  88.     HIBERNATE_MODULE="uswsusp"
  89.     do_hibernate()
  90.     {
  91.         s2disk
  92.     }
  93. fi
  94.  
  95. if [ -z "$SUSPEND_HYBRID_MODULE" ] && 
  96.     grep -q mem /sys/power/state && \
  97.     command_exists s2both && \
  98.     check_hibernate; then
  99.     SUSPEND_HYBRID_MODULE="uswsusp"
  100.     do_suspend_hybrid()
  101.     {
  102.         uswsusp_get_quirks
  103.         s2both --force $OPTS 
  104.     }
  105.     if [ "$METHOD" = "suspend_hybrid" ]; then
  106.         add_before_hooks uswsusp_hooks
  107.         add_module_help uswsusp_help
  108.     fi
  109. fi
  110.